# coding: utf-8
from sqlalchemy import Column, DateTime, String, Text, text
from sqlalchemy.dialects.mysql import INTEGER
from exts import db

Base =  db.Model
metadata = Base.metadata


class DAdmin(Base):
    __tablename__ = 'd_admin'

    id = Column(INTEGER(11), primary_key=True)
    name = Column(String(60, 'utf8_unicode_ci'))
    pwd = Column(String(80, 'utf8_unicode_ci'))
    status = Column(INTEGER(255), server_default=text("'0'"))
    update = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"))
    ip = Column(String(60, 'utf8_unicode_ci'))


class DCategory(Base):
    __tablename__ = 'd_category'

    id = Column(INTEGER(255), primary_key=True)
    name = Column(String(60, 'utf8_unicode_ci'))
    sort = Column(INTEGER(255), server_default=text("'0'"))
    status = Column(INTEGER(255), server_default=text("'0'"))
    addtime = Column(DateTime, server_default=text("CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP"))


class DMenu(Base):
    __tablename__ = 'd_menu'

    id = Column(INTEGER(11), primary_key=True)
    name = Column(String(60, 'utf8_unicode_ci'))
    icon = Column(String(60, 'utf8_unicode_ci'))
    url = Column(String(255, 'utf8_unicode_ci'))
    sort = Column(INTEGER(11), server_default=text("'0'"))
    status = Column(INTEGER(11), server_default=text("'0'"))
    pid = Column(INTEGER(11), server_default=text("'0'"))
    addtime = Column(DateTime, server_default=text("CURRENT_TIMESTAMP"))


class DNew(Base):
    __tablename__ = 'd_new'

    id = Column(INTEGER(10), primary_key=True)
    title = Column(String(255, 'utf8_unicode_ci'))
    content = Column(Text(collation='utf8_unicode_ci'))
    sort = Column(INTEGER(255), server_default=text("'0'"))
    status = Column(INTEGER(255), server_default=text("'0'"))
    cid = Column(INTEGER(11), server_default=text("'0'"))
    view = Column(INTEGER(255), server_default=text("'0'"))
    addtime = Column(DateTime)
    pic = Column(String(255, 'utf8_unicode_ci'))
